//package com.wjh.mirna.utils;
//
//import com.wjh.mirna.MirnaApplication;
//import com.wjh.mirna.model.Score;
//import com.wjh.mirna.service.impl.DiseaseServiceImpl;
//import com.wjh.mirna.service.impl.ScoreServiceImpl;
//import org.apache.poi.ss.usermodel.CellType;
//import org.apache.poi.xssf.usermodel.XSSFCell;
//import org.apache.poi.xssf.usermodel.XSSFRow;
//import org.apache.poi.xssf.usermodel.XSSFSheet;
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.SpringApplication;
//import org.springframework.context.ApplicationContext;
//
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.List;
//
//public class InsertScoreData {
//    @Autowired
//    static ScoreServiceImpl scoreService;
//    public static void main(String[] args) throws IOException {
//        SpringApplication.run(MirnaApplication.class,args);
//        ApplicationContext applicationContext = SpringContextUtil.getApplicationContext();
//        scoreService = applicationContext.getBean(ScoreServiceImpl.class);
//        String inputFilePath = "C:/Users/Administrator/Desktop/所有疾病预测结果.xlsx";
//        FileInputStream fileInput = new FileInputStream(inputFilePath);//创建文件输入流
//        XSSFWorkbook wb = new XSSFWorkbook(fileInput);//由输入流文件得到工作簿对象
//        XSSFSheet sheet = wb.getSheetAt(0);//获取第一个sheet
//        int lastRowNum = sheet.getLastRowNum(); //获取表格内容的最后一行的行数
//        ArrayList<Score> l = new ArrayList<>();
//        //rowBegin代表要开始读取的行号，下面这个循环的作用是读取每一行内容
//        for (int i = 0; i <= lastRowNum; ++i) {
//            List list = new ArrayList();
//            Score score = new Score();
//            XSSFRow row = sheet.getRow(i);//获取每一行
//            int columnNum = row.getLastCellNum();//获取每一行的最后一列的列号，即总列数
//            for (int j=0; j<columnNum; ++j) {
//                XSSFCell cell = row.getCell(j);//获取每个单元格
//                cell.setCellType(CellType.STRING);
//                String cellValue = cell.getStringCellValue();
//                System.out.println(cellValue);
//                list.add(cellValue);
//            }
//            score.setDname((String) list.get(0));
//            score.setMname((String) list.get(1));
//            score.setScore(Double.valueOf(list.get(2).toString()));
//            list.clear();
//            l.add(score);
//            System.out.println();
//        }
//        scoreService.insertScoreList(l);
//        wb.close();
//        fileInput.close();
//    }
//}
